<?php
class pk_feedsite extends BaseModel implements Retrievable {

 	var $sport;
 	var $name;
 	var $website;
 	var $url;
 	var $type;
 	var $lastcronjob;
	 	
    public function pk_feedsite($values) {
        parent::__construct($values);
    }

    public function validate() {
        $errors = Array();
		return (count($errors) === 0 ? true : $errors);
    }

    public static function get($id, $primaryKey='id') {
        return parent::get($id, __CLASS__, $primaryKey);
    }
    
    public static function getAll($searchArray=Array(), $sortArray=Array()) {
        return parent::getAll($searchArray, $sortArray, __CLASS__);
    }
    
    public static function getFeeds($sport) {
    	return pk_feedsite::getAll(array('sport'=>$sport));
    }
    
    public static function getBlogs($sport) {    	
    	$raw = AdroitDB::fetchRecords("pk_feed", array("pk_feedsite.sport"=>$sport), array("pk_feed.id", "DESC"), array("pk_feedsite"=>"pk_feed.feedsite=pk_feedsite.id"), 10);
    	$doms = Array();
        foreach($raw AS $values) {
            $doms[] = new pk_feed($values);
        }
        return $doms;
    }
    
    
}
?>